package com.sluggard.ai.controller;

import com.sluggard.common.model.res.Result;
import org.springframework.web.bind.annotation.*;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.multipart.MultipartFile;
import com.sluggard.ai.model.entity.KnowledgeFileEntity;
import com.sluggard.ai.service.IKnowledgeFileService;
import com.sluggard.ai.model.req.KnowledgeFileReq;
import com.sluggard.mp.mvc.BaseController;

/**
 * <p>
 * 知识库文件管理 前端控制器
 * </p>
 *
 * @author lizheng
 * @since 2025-04-23
 */
@Tag(name = "知识库文件管理")
@RestController
@RequestMapping("/knowledge/file")
public class KnowledgeFileController extends BaseController<KnowledgeFileReq, KnowledgeFileEntity, IKnowledgeFileService> {

    /**
     * 上传文件
     */
    @PostMapping("/upload")
    public Result<Void> upload(@RequestParam("file") MultipartFile file, @RequestParam("knowledgeId") Long knowledgeId) {
        service.upload(file, knowledgeId);
        return Result.ok();
    }

    /**
     * 上传文件
     */
    @PostMapping("/splitFile/{id}")
    public Result<Void> splitFile(@PathVariable("id") Long id) {
        service.splitFile(id);
        return Result.ok();
    }

}